package tablemodels;

import java.util.ArrayList;

import javax.swing.table.DefaultTableModel;

import utils.Expert;

/**
 * 
 * @author dernasherbrezon
 *
 */
public class ExpertModel extends DefaultTableModel
{
	private ArrayList<Expert> data;
	private String[] header = {"Имя эксперта","Роль эксперта"};
	
	public ExpertModel(ArrayList<Expert> data)
	{
		this.data = data;
	}
	

	@Override
	public Object getValueAt(int row, int column)
	{
		Expert curExpert = data.get(row);
		if(column==0)
		{
			return curExpert.name;
		}
		if(column==1)
		{
			return curExpert.role;
		}
		return null;
	}
	
	@Override
	public boolean isCellEditable(int row, int column)
	{
		return false;
	}
	
	@Override
	public int getRowCount()
	{
		if(data!=null)
		{
			return data.size();
		}
		return 0;
	}
	
	@Override
	public int getColumnCount()
	{
		return 2;
	}
	
	@Override
	public String getColumnName(int column)
	{
		return header[column];
	}
	
	public Expert getExpert(int index)
	{
		return data.get(index);
	}
	
	
	@Override
	public void fireTableDataChanged()
	{
		super.fireTableDataChanged();
	}
}
